// JavaScript Document

<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Husay :: http://www.communitxt.net */
var arrInput1 = new Array(0);
var arrInputValue1 = new Array(0);
var arrInput2 = new Array(0);
var arrInputValue2 = new Array(0);
var arrInput3 = new Array(0);
var arrInputValue3 = new Array(0);
var arrInput4 = new Array(0);
var arrInputValue4 = new Array(0);
var title = new Array();
title[0]="Mr";
title[1]="Mrs";
title[2]="Miss";
title[3]="Ms";
title[4]="Dr";
title[5]="Prof";

var crttxt;

function takevaluefromarray(frm)
{
	frm.hidemail.value=arrInputValue1;
	frm.hidfname.value=arrInputValue2;
	frm.hidlname.value=arrInputValue3;
	frm.hidtitle.value=arrInputValue4;
	
	if(frm.txtmanutitle.value.length<=0)
	{
		alert("Enter Manuscript title");
		frm.txtmanutitle.focus();
		return false;
	}
	else if(frm.txtkeywords.value.length<=0)
	{
		alert("Enter Manuscript Keywords");
		frm.txtkeywords.focus();
		return false;
	}
	else
	{
		//frm.samplevalue.value=arrInputValue;
		//document.frmaddedit.hidvalue.value=arrInput;
		return true;
	}
}


function addInput(name) {
  //arrInput.push(createInput(arrInput.length));
  //arrInput.push(arrInput.length);
  //arrInputValue.push(arrInputValue.length);
  //arrInputValue.push("");
  arrInput1.push(arrInput1.length);
  arrInputValue1.push("");
  arrInput2.push(arrInput2.length);
  arrInputValue2.push("");
  arrInput3.push(arrInput3.length);
  arrInputValue3.push("");
  arrInput4.push(arrInput4.length);
  arrInputValue4.push("Mr");
  display(name);
}

function display(name) {
  document.getElementById(name).innerHTML="";
  for (intI=0;intI<arrInput1.length;intI++) {
    document.getElementById(name).innerHTML+=createInput(intI);
  }
}

function saveValue(cond,intId,strValue,frm) {
	//alert(cond);
	
		/*var strtmp=frm.hidemail.value;
		var vars = strtmp.split(",");
		var cond=true;
		  for (var i=0;i<vars.length;i++)
		  {
			//alert("var=="+vars[i]);
			if ( Trim(vars[i]) ==intId ) 
			{
				cond=false;
				i=vars.length;
			}
			
		  } 
		if(cond==true)
		{
			frm.hidemail.value +=","+strValue;
		}
		
		
		var strtmp=frm.hidfname.value;
		var vars = strtmp.split(",");
		var cond=true;
		  for (var i=0;i<vars.length;i++)
		  {
			//alert("var=="+vars[i]);
			if ( Trim(vars[i]) ==intId ) 
			{
				cond=false;
				i=vars.length;
			}
			
		  } 
		if(cond==true)
		{
			frm.hidfname.value +=","+strValue;
		}
		
		
		var strtmp=frm.hidlname.value;
		var vars = strtmp.split(",");
		var cond=true;
		  for (var i=0;i<vars.length;i++)
		  {
			//alert("var=="+vars[i]);
			if ( Trim(vars[i]) ==intId ) 
			{
				cond=false;
				i=vars.length;
			}
			
		  } 
		if(cond==true)
		{
			frm.hidlname.value +=","+strValue;
		}*/
		
		if(cond==1)
		{
			arrInputValue1[intId]=strValue;
			arrInputValue2[intId]=arrInputValue2[intId];
			arrInputValue3[intId]=arrInputValue3[intId];
			arrInputValue4[intId]=arrInputValue4[intId];
		}
		if(cond==2)
		{
			arrInputValue2[intId]=strValue;
			arrInputValue1[intId]=arrInputValue1[intId];
			arrInputValue3[intId]=arrInputValue3[intId];
			arrInputValue4[intId]=arrInputValue4[intId];
		}
		if(cond==3)
		{
			arrInputValue3[intId]=strValue;
			arrInputValue2[intId]=arrInputValue2[intId];
			arrInputValue1[intId]=arrInputValue1[intId];
			arrInputValue4[intId]=arrInputValue4[intId];
		}
		if(cond==4)
		{
			
			arrInputValue4[intId]=strValue;
			arrInputValue2[intId]=arrInputValue2[intId];
			arrInputValue3[intId]=arrInputValue3[intId];
			arrInputValue1[intId]=arrInputValue1[intId];
		}
		
	//alert(document.frmaddedit.hidvalue.value);
	//arrInputValue1[intId]=strValue;
}  

function createInput(value) {
 crttxt="<select id='title"+ arrInput4[value] +"'  onChange='javascript:saveValue(4,"+ arrInput4[value] +",this.value,this.form)'>"; 
 	
	for(var i=0;i<title.length;i++)
	 {
		crttxt +="<option value='"+title[i]+"'";
		if(arrInputValue4[value]==title[i])
		{
			crttxt +=" Selected ";
		}
		 crttxt += " >"+title[i] + "</option>";
	 }
	 
  crttxt +="</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' id='txtemail"+ arrInput1[value] +"'  size=20 onChange='javascript:saveValue(1,"+ arrInput1[value] +",this.value,this.form)' value='"+ arrInputValue1[value] +"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' id='txtfirstname"+ arrInput2[value] +"'  size=20 onChange='javascript:saveValue(2,"+ arrInput2[value] +",this.value,this.form)' value='"+ arrInputValue2[value] +"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' id='txtlastname"+ arrInput3[value] +"'  size=20 onChange='javascript:saveValue(3,"+ arrInput3[value] +",this.value,this.form)' value='"+ arrInputValue3[value] +"'><br>";
  
  return crttxt;
}

function deleteInput(name) {
  if (arrInput1.length > 0) { 
  
     arrInput1.pop(); 
     arrInputValue1.pop();
  }
  if (arrInput2.length > 0) { 
  
     arrInput2.pop(); 
     arrInputValue2.pop();
  }
  if (arrInput3.length > 0) { 
  
     arrInput3.pop(); 
     arrInputValue3.pop();
  }
  if (arrInput4.length > 0) { 
  
     arrInput4.pop(); 
     arrInputValue4.pop();
  }
  display(name); 
  
}
// End -->



function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function